//
//  MessageCell.m
//  HuoFeiDaShipper
//
//  Created by mac on 2019/12/26.
//  Copyright © 2019 zhuchongjin. All rights reserved.
//

#import "MessageCell.h"
@interface MessageCell()
@property (nonatomic,strong) CJLabel *labTitle;
@property (nonatomic,strong) CJLabel *labTime;
@property (nonatomic,strong) CJLabel *labContent;
@property (nonatomic,strong) UIView *viewLine;
@property (nonatomic,strong) FlexTouchView *touchViewDetail;
@property (nonatomic,strong) CJLabel *labHavaRead;
@end
@implementation MessageCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

//- (void)setCellInfoWithDic:(NSDictionary *)dic{
//
//    if ([CJStringWithFormat(@"%@",dic[@"isSystem"]) isEqualToString:@"1"]) {
//        self.labTitle.text = @"系统消息";
//        self.touchViewDetail.hidden = YES;
//    }else {
//        self.labTitle.text = @"业务消息";
//        self.touchViewDetail.hidden = NO;
//    }
//    
//    self.labContent.text = dic[@"content"];
//    self.labTime.text = dic[@"pushTime"];
//}

- (void)touchViewDetaiAction{
    if (self.blockDetail) {
        self.blockDetail(@"");
    }
}

- (void)setCellInfoWithModel:(MessageModel *)model{
//    if (model.type == 1) {
//        self.labTitle.text = @"系统消息";
//    }else if (model.type == 0){
//        self.labTitle.text = @"业务消息";
//
//    }
    
    NSString * jsonString = model.extras;
    NSError *err;
    NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData
                                                    options:NSJSONReadingMutableContainers
                                                          error:&err];
    if ([[CJControl getThreeUnaryValueStr:dic[@"isSystem"]] intValue] == 0) {
        self.labTitle.text = @"业务消息";
//        self.touchViewDetail.hidden = YES;
//        self.viewLine.hidden = YES;
    }else{
        self.labTitle.text = @"系统消息";
//        self.touchViewDetail.hidden = NO;
//        self.viewLine.hidden = NO;
    }
    
    self.labContent.text = model.alert;
    self.labTime.text = [CJControl getThreeUnaryValueStr:dic[@"pushTime"]];
    
//    havaRead  0 未读
    if (model.havaRead.intValue == 0) {
        self.labHavaRead.text = @"未读";
        self.labHavaRead.textColor = [UIColor cjRedColor];
    }else{
        self.labHavaRead.text = @"已读";
        self.labHavaRead.textColor = [UIColor cjMainTextColor];
    }
}

//    {
//    pushTime = "2020-10-19 14:19:41",
//    isSystem = "0",
//    key = "2001",
//    name = "运单通知",
//    type = "2001",
//    params = "code=73be78cc182143e58eb4f3a40c96d638",
//}

@end
